package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author Liu Chang
 * @Date 2021/10/10 3:30 上午
 */
@Controller
@RequestMapping("/user")
public class UserController {


    IUserService userService = (IUserService) RpcClientProxy.createProxy(IUserService.class);

    @RequestMapping("/{id}")
    @ResponseBody
    public User getUserById(@PathVariable Integer id) {
        User user = userService.getById(id);
        System.out.println(user);
        return user;
    }
}
